package com.springboot.demo.service.impl;

import com.springboot.demo.domain.User;
import com.springboot.demo.repository.UserRepository;
import com.springboot.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserRepository userRepository;

    @Override
    public User getUserById(int userId) {
        return userRepository.getUserById(userId);
    }

    @Override
    public boolean addUser(User user) {
        User save = userRepository.save(user);
        return save.getId() > 0;
    }

    @Override
    public List<User> selectAllUser() {
        return userRepository.findAll();
    }
}
